/*
  Tên:Huỳnh Nguyễn Ngọc Hân
  MSSV:11370551
  Lớp:DHTH7DLT
  Ngày hoàn thành:28/04/2012
  */
#include "frdangnhap.h"
#include "ui_frdangnhap.h"
#include <QtSql>
#include "QModelIndex"
#include <QAbstractItemModel>
#include <QItemSelection>
#include <QItemSelectionModel>
#include <QDialogButtonBox>


frDangNhap::frDangNhap(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::frDangNhap)
{
    ui->setupUi(this);
    DB=new MySqlConnection();

}

frDangNhap::~frDangNhap()
{
    delete ui;
}

bool frDangNhap::validateLogin()
{

    QString TenDN, MatKhau;
    TenDN=ui->txtten->text();
    MatKhau=ui->txtmatkhau->text();
    if(TenDN.isEmpty()||MatKhau.isEmpty())
    {
        return 0;
    }

    QSqlQueryModel *model = DB->DangNhap(TenDN);

    QString dbmatkhau=model->record(0).value(0).toString();
    if((MatKhau ==  dbmatkhau))
        return 1;
    return 0;
}
void frDangNhap::changeEvent(QEvent *e)
{
    QDialog::changeEvent(e);
        switch (e->type()) {
        case QEvent::LanguageChange:
            ui->retranslateUi(this);
            break;
        default:
            break;
        }
}
